<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
 <head>
  <title>机房</title>
  <t:base type="jquery,easyui,tools,DatePicker"></t:base>
   <script src="plug-in/jquery-plugs/form/jquery.form.js"></script>
  <script type="text/javascript" charset="utf-8" src="plug-in/ueditor/ueditor.config.js"></script>
   <script type="text/javascript" charset="utf-8" src="plug-in/ueditor/ueditor.all.min.js"> </script> 
   <script type="text/javascript" charset="utf-8" src="plug-in/ueditor/lang/zh-cn/zh-cn.js"></script>
   <script type="text/javascript" src="plug-in/Validform/js/Validform_v5.3.1_min_zh-cn.js"></script>
   <script type="text/javascript" src="plug-in/Validform/js/Validform_Datatype_zh-cn.js"></script>
   <script type="text/javascript" src="plug-in/Validform/js/datatype_zh-cn.js"></script>
   <link rel="stylesheet" href="plug-in/Validform/css/style.css" type="text/css">
   <link rel="stylesheet" href="plug-in/Validform/css/tablefrom.css" type="text/css">
   
   <!-- 上传文件  -->
    <link rel="stylesheet" type="text/css" href="plug-in/webUploader/css/webuploader.css" />
    <link rel="stylesheet" type="text/css" href="plug-in/webUploader/style.css" />
    <script type="text/javascript" src="plug-in/webUploader/dist/webuploader.js"></script>
     <script type="text/javascript" src="plug-in/webUploader/third/uploadImg.js"></script>
   
  	<style>
  		.prevImg{
  			float:left;
  			margin:2px;
  		}
  		.prevImg a{
  			display: block;
    		text-align: center;
    		cursor:pointer;
    		color:rgb(0,162,212)
  		}
  	</style>
 </head>
 <body>
 
  <form id="formobj" enctype="multipart/form-data" action="cms-device.do?doAdd" name="formobj" method="post">
  		<input type="hidden" id="btn_sub" class="btn_sub">
  		<input type="hidden" id="id" name="id" value="${device.id}"/>
					 
		<table style="" cellpadding="0" cellspacing="1" class="formtable">
			<tbody>
				<tr>
					<td align="right">
						<label class="Validform_label">
							设备名称:
						</label>
					</td>
					<td class="value">
					    <input onkeypress="specialTextValidate()" id="title" name="title" type="text" 
					     	 style="width: 150px" class="inputxt" value="${device.title }" datatype="*">
						<span class="Validform_checktip"></span>
						<label class="Validform_label" style="display: none;">设备名称</label>
					</td>
				</tr>
				<tr>
					<td align="right">
						<label class="Validform_label">
							设备编号:
						</label>
					</td>
					<td class="value">
					     	 <input onkeypress="specialTextValidate()" id="deviceNo" name="deviceNo" 
					     	 type="text" style="width: 150px" class="inputxt" datatype="*" value="${device.deviceNo}">
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">设备编号</label>
					</td>
				</tr>
				<tr>
					<td align="right">
						<label class="Validform_label">
							设备品牌:
						</label>
					</td>
					<td class="value">
					     	<input onkeypress="specialTextValidate()" id="brand" name="brand" 
					     	type="text" style="width: 150px" class="inputxt"  value="${device.brand}">
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">设备品牌</label>
					</td>
				</tr>
				<tr>
					<td align="right">
						<label class="Validform_label">
							设备型号:
						</label>
					</td>
					<td class="value">
					     	<input onkeypress="specialTextValidate()" id="deviceModel" name="deviceModel" 
					     	type="text" style="width: 150px" class="inputxt" value="${device.deviceModel}">
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">设备型号</label>
					</td>
				</tr>
				<tr>
					<td align="right">
						<label class="Validform_label">
							序号:
						</label>
					</td>
					<td class="value">
					    <input onkeypress="numberValidate()" id="sortOrder" name="sortOrder" 
					    type="text" style="width: 150px" class="inputxt" datatype="n" value="${device.sortOrder}">
						<span class="Validform_checktip"></span>
						<label class="Validform_label" style="display: none;">序号</label>
					</td>
				</tr>
				
				<tr>
					<td align="right">
						<label class="Validform_label">
							照片:
						</label>
					</td> 
					<td class="value"> 
		         		
		         		<c:forEach items="${attList}" var="att">
		         			<div class="prevImg" id="prevImg${att.id}">
		         				<img src="cms-attach.do?get&attachId=${att.id }" style="height:80px;width:80px">
		         				<a onclick='deleteAttach(${att.id})'>删&nbsp;除</a>
		         			</div>  	 
		         		</c:forEach> 
		         		
		         		 <div id="wrapper">
					        <div id="container">
					            <!--头部，相册选择和格式选择-->
					
					            <div id="uploader">
					                <div class="queueList">
					                    <div id="dndArea" class="placeholder">
					                        <div id="filePicker"></div>
					                        <p>或将照片拖到这里，单次最多可选6张</p>
					                    </div>
					                </div>
					                <div class="statusBar" style="display:none;">
					                    <div class="progress">
					                        <span class="text">0%</span>
					                        <span class="percentage"></span>
					                    </div><div class="info"></div>
					                    <div class="btns">
					                        <div id="filePicker2"></div><div class="uploadBtn">开始上传</div>
					                    </div>
					                </div>
					            </div>
					        </div>
   						</div>
		           </td> 
			  </tr>
			  
			  <tr>
		         <td>
		         	<div style='line-height:30px;'>设备描述：</div>
		       	</td>
		       	<td> 
		         	<script name='content' id="detailEditor" type="text/plain" style="width:700px;height:200px;">${device.content}</script>
		         </td>
		      </tr> 
			</tbody>
		</table>
		</form>
		
		<script>
			
			 $(document).ready(function () {
				 
				var validForm = $('#formobj').Validform({tiptype:"3"}); //初始化校验form控件
				
				//判断是否是查看页面,不是查看页面，初始化编辑器
				if(location.href.indexOf("load=detail")==-1){
					UE.getEditor("detailEditor",{});//初始化editor控件
				}else{
					UE.getEditor("detailEditor",{
						readonly:true, 
						toolbars: []
					});//初始化editor控件
				}
				  
				
				// ajaxSubmit
				$("#btn_sub").click(function () {
					var valid = validForm.check(false);
					if(!valid) return;
					
				     $("#formobj").ajaxSubmit({success: function (data) {
				    	data = $.parseJSON(data);
				        if(data.success){
				        	window.top.tip("保存成功！");
				        	frameElement.api.opener.reloadTable();
				        	frameElement.api.close();
				        	
				        }else{
				        	tip(data.msg);
				        }
					 }});
				});
			});
			
			function deleteAttach(id){
				 $('#prevImg'+id).remove();
				 $('#formobj').append("<input type='hidden' name='deletedAttach'  value='"+id+"'/>");
			}
		 
		</script>
 </body>
 